#include <bits/stdc++.h>

#define ll long long
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
const int INF = 1e9;
using namespace std;
/*思考区

*/
void solve()
{
    int n = 0;
    cin >> n;
    vector<int> a(n + 2,0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    if (accumulate(a.begin(), a.end(), 0) == n) {
        YES;
        return;
    }
    for (int i = 2; i <= n; i++) {
        if (a[i] == 0 && a[i - 1] == 0) {
            YES;
            return;
        }
    }
    NO;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 0;
    cin >> t;
    while (t--)
        solve();
    return 0;
}